package raft.entity;

import javafx.util.Builder;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class RvoteParam extends BaseParam {

    /**
     * 候选人id
     */
    String candidateId;

    /**
     *  最后一个日志索引
     */
    long lastLogIndex;

    /**
     * 最后一个日志任期
     */
    long lastLogTerm;

    private RvoteParam(Builder builder){
        setTerm(builder.term);
        setServiceId(builder.serviceId);
        setCandidateId(builder.candidateId);
        setLastLogIndex(builder.lastLogIndex);
        setLastLogTerm(builder.lastLogTerm);
    }

    @Override
    public String toString() {
        return "RvoteParam{" +
                "term=" + term +
                ", serviceId='" + serviceId + '\'' +
                ", candidateId='" + candidateId + '\'' +
                ", lastLogIndex='" + lastLogIndex + '\'' +
                ", lastLogTerm='" + lastLogTerm + '\'' +
                '}';
    }

    public static Builder newBuilder(){
        return new Builder();
    }

    public static final class Builder{
        String candidateId;

        long lastLogIndex;

        long lastLogTerm;

        private long term;

        private String serviceId;

        public  Builder(){

        }

        public Builder term(long val ){
            term = val;
            return this;
        }

        public Builder serviceId(String val ){
            serviceId = val;
            return this;
        }

        public Builder lastLogTerm(long val ){
            lastLogTerm = val;
            return this;
        }

        public Builder lastLogIndex(long val ){
            lastLogIndex = val;
            return this;
        }

        public Builder candidateId(String val ){
            candidateId = val;
            return this;
        }

        public RvoteParam build(){
            return new RvoteParam(this);
        }

    }


    public static void main(String[] args) {
        RvoteParam param  =   RvoteParam.newBuilder().candidateId("候选者一号").serviceId("22").term(1).build();
         


    }



}
